home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Science⁄Math / Scientist's Helper src / s.helper.4 / regmenu.c < prev    next >
C/C++ Source or Header  |  1986-01-17  |  4KB  |  179 lines

  1. #include "all.h"
  2. #include "regtabext.h"
  3.  
  4. DoCommand(mResult)
  5. unsigned long mResult;
  6. {
  7.     int moveToScrap;
  8.     Handle TEScrH;
  9.     char name[30];
  10.     short theMenu, theItem;
  11.     Point p;
  12.     SFReply reply;
  13.     WindowPtr oldWindow;
  14.     GrafPtr    oldPort;
  15.  
  16.     theMenu = mResult >> 16;
  17.     theItem = mResult;
  18.     
  19.     p.h = 100;
  20.     p.v = 100;
  21.     
  22.     moveToScrap = FALSE;
  23.  
  24.     switch (theMenu) {
  25.     
  26.         case apMenuRes :
  27.             GetItem(myMenu[0],theItem,name);
  28.             OpenDeskAcc(name);
  29.             break;
  30.             
  31.         case fiMenuRes :
  32.             switch(theItem) {
  33.                 case 1: /*read table*/
  34.                     strcpy(name,"RGTB");
  35.                     SFGetFile( pass(p), "\P ", 0L, 1, name, 0L, &reply );
  36.                     ReadTable(&reply);
  37.                     break;
  38.                 case 2: /*write table*/
  39.                     SFPutFile( pass(p), "\PSave Table as . . .", "\PUntitled Table",
  40.                         0L, &reply );
  41.                     WriteTable(&reply);
  42.                     break;
  43.                 case 4: /*read ascii table*/
  44.                     strcpy( name,  "TEXT" );
  45.                     SFGetFile( pass(p), "\P ", 0L, 1, name, 0L, &reply );
  46.                     ReadAsciiTable(&reply);
  47.                     break;
  48.                 case 5: /*write ascii table table*/
  49.                     SFPutFile( pass(p), "\PSave Table as . . . ", "\PUntitled Ascii Table",
  50.                         NULL, &reply );
  51.                     WriteAsciiTable(&reply);
  52.                     break;
  53.                 case 7: /*load procedure*/
  54.                     strcpy( name,  "TEXT" );
  55.                     SFGetFile( pass(p), "\P ", 0L, 1, name, 0L, &reply );
  56.                     ReadProcedure(&reply);
  57.                     break;
  58.                 case 8: /*save procedure as*/
  59.                     SFPutFile( pass(p), "\PSave Procedure as . . . ", "\PUntitled Procedure",
  60.                         NULL, &reply );
  61.                     WriteProcedure(&reply);
  62.                     break;
  63.                 case 10: /*MacWrite Graph*/
  64.                     SFPutFile( pass(p), "\PSave graph as . . . ", "\PUntitled Graph",
  65.                         NULL, &reply );
  66.                     WriteGraph(&reply);
  67.                     break;
  68.                 case 12:  /* quit */
  69.                         doneFlag = TRUE;
  70.                     break;
  71.                 } /*end switch theItem*/
  72.             break;
  73.             
  74.         case edMenuRes :
  75.             if( SystemEdit(theItem-1) ) break;
  76.             oldWindow = whichWindow;
  77.             whichWindow = FrontWindow();
  78.             GetPort( &oldPort );
  79.             GetWndNumber(whichWindow);
  80.             SetPort( whichWindow );
  81.             switch(theItem) {
  82.             
  83.                 case 1: /*undo*/
  84.                     /*undo does nothing*/
  85.                     break;
  86.                     
  87.                 case 3: /*cut*/
  88.                     if( whichWindow == theWindow[coWindow] ) {
  89.                         TECut( coText );
  90.                         moveToScrap=TRUE;
  91.                         }
  92.                     else if (whichWindow == theWindow[prWindow]) {
  93.                         TECut( prText );
  94.                         moveToScrap=TRUE;
  95.                         }
  96.                     else if (whichWindow == theWindow[edWindow]) {
  97.                         TECut( edText );
  98.                         moveToScrap=TRUE;
  99.                         }
  100.                     break;
  101.  
  102.                 case 4: /*copy*/
  103.                     if( whichWindow == theWindow[coWindow] ) {
  104.                         TECopy( coText );
  105.                         moveToScrap=TRUE;
  106.                         }
  107.                     else if ( whichWindow == theWindow[prWindow]) {
  108.                         TECopy( prText );
  109.                         moveToScrap=TRUE;
  110.                         }
  111.                     else if ( whichWindow == theWindow[edWindow]) {
  112.                         TECopy( edText );
  113.                         moveToScrap=TRUE;
  114.                         }
  115.                     break;
  116.                     
  117.                 case 5: /*paste*/
  118.                     if( whichWindow == theWindow[coWindow] ) {
  119.                         TEPaste( coText );
  120.                         IfOutScroll(coText);
  121.                         }
  122.                     else if (whichWindow == theWindow[prWindow]) {
  123.                         TEPaste( prText );
  124.                         IfOutScroll(prText);
  125.                         }
  126.                     else if (whichWindow == theWindow[edWindow]) {
  127.                         TEPaste( edText );
  128.                         }
  129.                     break;
  130.                     
  131.                 case 6: /*clear*/
  132.                     /*clear does nothing*/
  133.                     break;
  134.                     
  135.                 } /*end switch theItem*/
  136.                 
  137.             whichWindow = oldWindow;
  138.             SetPort( oldPort );
  139.             GetWndNumber(whichWindow);
  140.             break;
  141.             
  142.         case wiMenuRes :
  143.             switch(theItem) {
  144.                 case 1:
  145.                     SelectWindow(theWindow[coWindow]);
  146.                     break;
  147.                 case 2:
  148.                     SelectWindow(theWindow[grWindow]);
  149.                     break;
  150.                 case 3:
  151.                     SelectWindow(theWindow[prWindow]);
  152.                     break;
  153.                 case 4:
  154.                     SelectWindow(theWindow[edWindow]);
  155.                     break;
  156.                 } /*end switch theItem*/
  157.             break;
  158.                 
  159.         case abMenuRes :
  160.             switch(theItem) {
  161.                 case 1:
  162.                     ErrMsg("Abort!");
  163.                     break;
  164.                 } /*end switch theItem*/
  165.             break;
  166.     } /*end switch theMenu*/
  167.     
  168.     if (moveToScrap) {
  169.         TEScrH=TEScrapHndl();
  170.         HLock(TEScrH);
  171.         ZeroScrap();
  172.         PutScrap( TEGetScrpLen(), 'TEXT', *TEScrH );
  173.         HUnlock(TEScrH);
  174.         scrapIndex = (InfoScrap())->scrapCount;
  175.         }
  176.         
  177.     HiliteMenu(0);
  178. }
  179.